package com.ctshk.rpc.ship.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctshk.common.utils.EntityUtil;
import com.ctshk.rpc.ship.dto.MainDataShipCompanyListDTO;
import com.ctshk.rpc.ship.dto.ShipConstants;
import com.ctshk.rpc.ship.entity.MainDataShipCompany;
import com.ctshk.rpc.ship.mapper.MainDataShipCompanyMapper;
import com.ctshk.rpc.ship.service.IMainDataShipCompanyService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 船票公司主数据 服务实现类
 * </p>
 *
 * @author 刘蕾
 * @since 2021-04-13
 */
@DubboService
public class MainDataShipCompanyServiceImpl extends ServiceImpl<MainDataShipCompanyMapper, MainDataShipCompany> implements IMainDataShipCompanyService {

    @Autowired
    private MainDataShipCompanyMapper mainDataShipCompanyMapper;

    @Override
    public List<MainDataShipCompanyListDTO> queryMainDataList() {
        List<MainDataShipCompany> mainDataShipCompanies = mainDataShipCompanyMapper.selectList(new QueryWrapper<MainDataShipCompany>().lambda()
                .eq(MainDataShipCompany::getIsDeleted, ShipConstants.NOT_DELETE));
        return EntityUtil.copyList(mainDataShipCompanies, MainDataShipCompanyListDTO.class);
    }

    @Override
    public List<MainDataShipCompanyListDTO> queryMainData(String name) {
        QueryWrapper<MainDataShipCompany> wrapper = new QueryWrapper<>();
        wrapper.lambda().like(MainDataShipCompany::getContent,name);
        List<MainDataShipCompany> mainDataShipCompany = mainDataShipCompanyMapper.selectList(wrapper);
        return EntityUtil.copyList(mainDataShipCompany, MainDataShipCompanyListDTO.class);
    }
}
